package com.ly.datacenter.component.pager.pojo;

import java.util.List;

import com.ly.datacenter.pojo.KeyValue;

/**
 * function：
 * @author watson  email: watson.wu@hotmail.com
 * @date 2009-9-4
 */
public class Pager {
	
	public static final String PAGE = "page";
	public static final int PAGESIZE = 10;

	private int totalSize;//total size of records
	private int pageSize;//the number of record in one page
	private int page;
	private List<List<KeyValue>> list;
	private int pageIndex;//page index
	private int totalPages;//total pages
	private String pk;

	/**
	 * 
	 * @param page
	 * @param pageSize
	 * @param totalSize
	 * @param list
	 */
	public Pager(int page, int pageSize, int totalSize, List<List<KeyValue>> list, String pk) {
		this.page = page==0?1:page;
		this.pageSize = pageSize==0?PAGESIZE:pageSize;
		this.totalSize = totalSize;
		this.list = list;
		pageIndex = page-1;
		totalPages = totalSize%this.pageSize==0?totalSize/this.pageSize:totalSize/this.pageSize+1;
		this.pk = pk;
	}

	public int getTotalSize() {
		return totalSize;
	}

	public void setTotalSize(int totalSize) {
		this.totalSize = totalSize;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public int getPageIndex() {
		return pageIndex;
	}

	public void setPageIndex(int pageIndex) {
		this.pageIndex = pageIndex;
	}

	public int getTotalPages() {
		return totalPages;
	}

	public void setTotalPages(int totalPages) {
		this.totalPages = totalPages;
	}

	public List<List<KeyValue>> getList() {
		return list;
	}

	public void setList(List<List<KeyValue>> list) {
		this.list = list;
	}

	public String getPk() {
		return pk;
	}

	public void setPk(String pk) {
		this.pk = pk;
	}

}

